from django.db import models
import uuid
# Create your models here.
"""
Django 数据库迁移命令: 
python manage.py makemigrations
python manage.py migrate
"""

"""
收藏夹查看链接:
- 用户收藏夹,其他用户可以查看该收藏夹下的文章
- Collection: 收藏夹
- CollectionItem: 收藏夹下的文章
"""
class Collection(models.Model):
    tkid = models.UUIDField(primary_key=True, default=uuid.uuid4)
    name = models.CharField(max_length=10)
    created_at = models.DateTimeField(auto_now_add=True)
    # 访问次数
    visit_count = models.IntegerField(default=0)
    def save(self, *args, **kwargs):
        
        # 保存
        super().save(*args, **kwargs)

class CollectionItem(models.Model):
    tkid = models.ForeignKey(Collection, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)
    title = models.CharField(max_length=100)
    url = models.CharField(max_length=200)
    cover = models.CharField(max_length=200)
    # 线路
    line = models.IntegerField(default=0)
    def save(self, *args, **kwargs):
        # 保存
        super().save(*args, **kwargs)

   